home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Add-Ons / 4D / ComboBox 1.1.1 / src / ComboBoxList.c < prev    next >
C/C++ Source or Header  |  1996-02-23  |  5KB  |  197 lines

  1. //---------------------------------------------------------------------------------------
  2. //
  3. //    ComboBoxList.c -- Source for ComboBox external list window process event handler
  4. //
  5. //    Copyright ©1995-1996, Pensacola Christian College
  6. //
  7. //    ======================================================================
  8. //    Change History
  9. //    ======================================================================
  10. //
  11. //    1.0            08/  /95        Steve Dwire
  12. //                                            Initial release
  13. //
  14. //---------------------------------------------------------------------------------------
  15.  
  16. #include <Ext4D.h>
  17. #include <QuickDraw.h>
  18. #include <Palettes.h>
  19. #include "ComboBoxList.h" // Include your header here.
  20.  
  21.  
  22. //---------------------------------------------------------------------------------
  23. //
  24. // FUNCTION: ListProcess
  25. //
  26. //---------------------------------------------------------------------------------
  27. #if defined(powerc) || WINVER
  28. void ListProcess(void)
  29. #else
  30. void main(void)
  31. #endif
  32. {
  33.     AreaHnd            OldAreaHnd=NULL, CurrAreaHnd=NULL;
  34.     Boolean            Done=false;
  35.     PackHnd            PackDataHnd;
  36.     WindowPtr        ListWindow;
  37.     EventRecord event;
  38.         
  39.     ListProcInit(&PackDataHnd, &ListWindow);
  40.  
  41.     while (!Done)
  42.     {
  43.         SystemTask();
  44.         if (WaitNextEvent(everyEvent,&event,60,NULL) && (event.what != kIdleEvt))
  45.         {
  46.             if(event.what == kTerminateProcess)
  47.             {
  48.                 Done=true;
  49.             }
  50.             else
  51.             {
  52.                 //Check status of current area
  53.                 CurrAreaHnd = (*PackDataHnd)->CurrAreaHnd;
  54.                 if(CurrAreaHnd)
  55.                 {
  56.                     // OK, now we can take care of the event we got.
  57.                     switch(event.what)
  58.                     {
  59.                         case mouseDown:
  60.                             ListMouseDown(CurrAreaHnd,&event,ListWindow);
  61.                             break;
  62.                         case updateEvt:
  63.                             ListUpdate(CurrAreaHnd,&event,ListWindow);
  64.                             break;
  65.                         case activateEvt:
  66.                             ListActivate(CurrAreaHnd,&event,ListWindow);
  67.                             break;
  68.                     }
  69.                 }
  70.             }
  71.         }
  72.     }
  73.     ListProcDeInit(PackDataHnd,ListWindow);
  74. }
  75.  
  76.  
  77. //---------------------------------------------------------------------------------
  78. //
  79. // FUNCTION: ListProcInit
  80. //
  81. //---------------------------------------------------------------------------------
  82.  
  83. void ListProcInit(PackHnd* PackDataHndPtr, WindowPtr* ListWndPtr)
  84. {
  85.     // Get the package handle out of ◊CB_PackData and store it in PackDataHnd.
  86.     ParameterBlock     block;
  87.     ValuePtr                value;
  88.     Rect                        bounds;
  89.     SWORD                        i;
  90.     
  91.     for(i=1; i<=3; i++)
  92.         CALL4D (kEX_YIELD_ABSOLUTE,&block);
  93.  
  94.     block.fName[0] = (SBYTE)11;
  95.     block.fName[1] = 'C';
  96.     block.fName[2] = 'B';
  97.     block.fName[3] = '_';
  98.     block.fName[4] = 'P';
  99.     block.fName[5] = 'a';
  100.     block.fName[6] = 'c';
  101.     block.fName[7] = 'k';
  102.     block.fName[8] = 'D';
  103.     block.fName[9] = 'a';
  104.     block.fName[10] = 't';
  105.     block.fName[11] = 'a';
  106.     block.fName[12] = '\0';
  107.     
  108.     value = (ValuePtr) NewPtr(sizeof(ValueBlock));
  109.     block.fH = (XHANDLE)value;
  110.     
  111.     CALL4D(kEX_GET_GLOBALVAR,&block);
  112.  
  113.     *PackDataHndPtr = (PackHnd)(value->uValue.fLongint);
  114.     DisposePtr((Ptr) value);
  115.  
  116.     // Create new (invisible) window for the lists
  117.     bounds.top = bounds.left = 1;
  118.     bounds.right = bounds.bottom = 2; // We'll resize the window before opening it
  119.     
  120.     CALL4D(kEX_FLOATING_WINDOW,&block);
  121.     *ListWndPtr = NewCWindow(NULL,&bounds,NULL,false,plainDBox,NULL,false,0);
  122.     
  123.     (**PackDataHndPtr)->ListWindow = *ListWndPtr;
  124.     CALL4D(kEX_CURRENT_ID,&block);
  125.     CALL4D(kEX_FREEZE_PROCESS,&block);
  126. }
  127.  
  128.  
  129. //---------------------------------------------------------------------------------
  130. //
  131. // FUNCTION: ListUpdate
  132. //
  133. //---------------------------------------------------------------------------------
  134.  
  135. void ListUpdate(AreaHnd AreaDataHnd, EventRecord* event, WindowPtr ListWindow)
  136. {
  137.     GrafPtr                    savePort;
  138.     ListHandle            ListHnd;
  139.     ParameterBlock    block;
  140.     
  141.     while((*AreaDataHnd)->Flags.ListDirty) // make sure the list is stable 
  142.         CALL4D(kEX_YIELD_ABSOLUTE,&block);    // before we draw it.
  143.             
  144.     ListHnd = (*AreaDataHnd)->ListHnd;
  145.     if (ListHnd)
  146.     {
  147.         //saveListPort = (*ListHnd)->port;
  148.         
  149.         GetPort(&savePort);
  150.         SetPort(ListWindow);
  151.         BeginUpdate(ListWindow);
  152.         //(*ListHnd)->port = savePort;
  153.         LUpdate(ListWindow->visRgn,ListHnd);
  154.         //(*ListHnd)->port = saveListPort;
  155.         
  156.         EndUpdate(ListWindow);
  157.         SetPort(savePort);
  158.     }
  159. }
  160.  
  161.  
  162. //---------------------------------------------------------------------------------
  163. //
  164. // FUNCTION: ListActivate
  165. //
  166. //---------------------------------------------------------------------------------
  167.  
  168. void ListActivate(AreaHnd AreaDataHnd, EventRecord* event, WindowPtr ListWindow)
  169. {
  170.     GrafPtr    savePort;
  171.     if((*AreaDataHnd)->ListHnd)
  172.     {
  173.         GetPort(&savePort);
  174.         SetPort(ListWindow);
  175.         //LActivate(((event->modifiers & activeFlag) != 0), (*AreaDataHnd)->ListHnd);
  176.         LActivate(true, (*AreaDataHnd)->ListHnd);
  177.         SetPort(savePort);
  178.     }
  179. }
  180.  
  181.  
  182. //---------------------------------------------------------------------------------
  183. //
  184. // FUNCTION: ListProcDeInit
  185. //
  186. //---------------------------------------------------------------------------------
  187.  
  188. void ListProcDeInit(PackHnd PackDataHnd, WindowPtr ListWindow)
  189. {
  190.     ParameterBlock    block;
  191.     
  192.     (*PackDataHnd)->ListWindow = NULL;
  193.     CloseWindow(ListWindow);
  194.     
  195.     CALL4D(kEX_KILL_PROCESS,&block);
  196. }
  197.